package com.eugene.element;

import java.io.Serializable;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.eugene.entity.MvData;

public class Underlying implements Serializable{
	private final static Logger logger = LoggerFactory.getLogger(Underlying.class);
	
	private FnCalendar baseDate;
	private String underlyingId;
	private String riskFactorId;
	private MvData riskFactor;
	private double weight;
	private double currentPrice;
	private double irRate;
	private double vol;
	private double covariance;
	private double beta;
	private Date lastUpdate;
	public FnCalendar getBaseDate() {
		return baseDate;
	}
	public void setBaseDate(FnCalendar baseDate) {
		this.baseDate = baseDate;
	}
	public String getUnderlyingId() {
		return underlyingId;
	}
	public void setUnderlyingId(String underlyingId) {
		this.underlyingId = underlyingId;
	}
	public String getRiskFactorId() {
		return riskFactorId;
	}
	
	public MvData getRiskFactor() {
		return riskFactor;
	}
	public void setRiskFactor(MvData riskFactor) {
		this.riskFactor = riskFactor;
	}
	public void setRiskFactorId(String riskFactorId) {
		this.riskFactorId = riskFactorId;
	}
	public double getWeight() {
		return weight;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
	
	public double getCurrentPrice() {
		return currentPrice;
	}
	public void setCurrentPrice(double currentPrice) {
		this.currentPrice = currentPrice;
	}
	
	public double getIrRate() {
		return irRate;
	}
	public void setIrRate(double irRate) {
		this.irRate = irRate;
	}
	public double getVol() {
		return vol;
	}
	public void setVol(double vol) {
		this.vol = vol;
	}
	public double getCovariance() {
		return covariance;
	}
	public void setCovariance(double covariance) {
		this.covariance = covariance;
	}
	public double getBeta() {
		return beta;
	}
	public void setBeta(double beta) {
		this.beta = beta;
	}
	public Date getLastUpdate() {
		return lastUpdate;
	}
	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	
	public Underlying(){
		
	}
	public Underlying(FnCalendar baseDate, String underlyingId, String rfId, double weight, double curPrice
							,double irRate,double vol, double covar, double beta){
		this.baseDate = baseDate;
		this.underlyingId = underlyingId;
		this.riskFactorId = rfId;
		this.weight = weight;
		this.currentPrice = curPrice;
		this.irRate =irRate;
		this.vol	= vol;
		this.covariance =covar;
		this.beta	= beta;
	}
	public Underlying(String underlyingId, String rfId, double weight, double curPrice, double irRate,double beta){
		this.underlyingId =underlyingId;
		this.riskFactorId =rfId;
		this.weight =weight;
		this.currentPrice =curPrice;
		this.irRate = irRate;
		this.beta = beta;
	}
	public Underlying(String underlyingId, String rfId, double weight, double beta){
		this.underlyingId =underlyingId;
		this.riskFactorId =rfId;
		this.weight = weight;
		this.beta	= beta;
	}
	
	public Underlying(String underlyingId, String rfId,  double beta){
		this.underlyingId =underlyingId;
		this.riskFactorId =rfId;
		this.weight = 1.0;
		this.beta	= beta;
	}
	
	public double getRiskPremium(double marketReturn){
		double rst;
//		logger.debug("{},{}", getBeta(), getCurrentPrice());
		rst = getBeta()* (marketReturn- getIrRate())* getWeight();
		return rst;
	}

	
	
	@Override
	public boolean equals(Object other){
		return super.equals(other); 
	}
	@Override
	public int hashCode(){
		return super.hashCode();
	}
}
